package io;

import java.io.*;

public class ObjectStreamTest {
    public static void main(String[] args) {
        File file = new File("D:\\test\\Person.txt");
        try {
//            FileOutputStream fos = new FileOutputStream(file,true);
//            ObjectOutputStream oos = new ObjectOutputStream(fos);
//            Person person = new Person("津少",19);
//            oos.writeObject(person);
//            oos.flush();
            FileInputStream fis = new FileInputStream(file);
            ObjectInputStream ois = new ObjectInputStream(fis);
            Person person = (Person)ois.readObject();
            System.out.println(person.toString());
            person.eat();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
